/*
 * @Date         : 2024-05-11 17:04:41 星期6
 * @Author       : xut
 * @Description  :
 */
import grpc from "@grpc/grpc-js"
import helloProto from "./helloworld.proto.js"
import { readFileSync } from "node:fs"

// 读取证书文件
const clientCrt = readFileSync("server.crt")
// 创建 SSL 证书
const credentials = grpc.credentials.createSsl(clientCrt)

const client = new helloProto.Greeter("localhost:50051", credentials)

client.sayHello({ name: "tom" }, function (err, res) {
  if (err) {
    console.error(err)
    return
  }
  console.log("Greeting: ", res.message)
})
